package com.tongjie.hotelbooking.http;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BaseResponse<T> {

    private Integer code;

    private String message;

    private T data;

    public static <T> BaseResponse<T> success() {
        return BaseResponse.<T>builder().code(200).message("success").build();
    }

    public static <T> BaseResponse<T> success(T data) {
        return BaseResponse.<T>builder().code(200).data(data).build();
    }

    public static <T> BaseResponse<T> fail(Integer code, String message, T data) {
        return BaseResponse.<T>builder().code(code).message(message).data(data).build();
    }

    public static <T> BaseResponse<T> fail(String message, T data) {
        return BaseResponse.fail(500, message, data);
    }

    public static <T> BaseResponse<T> fail(String message) {
        return BaseResponse.fail(500, message, null);
    }

}
